package com.duomn.mybatis.sample.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.duomn.mybatis.common.dao.impl.MybatisBaseDao;
import com.duomn.mybatis.sample.dao.ISampleDao;
import com.duomn.mybatis.sample.entity.Sample;

@Repository
public class SampleDaoMybatis extends MybatisBaseDao<Sample, String> implements ISampleDao {

	@Override
	public List<Sample> listSample() {
		return super.queryList("SampleMapping.querySampleList", null);
	}
	
	@Override
	public Integer saveSample(Sample sample) {
		return super.exec("SampleMapping.save", sample);
	}

	@Override
	public Integer updateSample(Integer id, Sample sample) {
		Map<String, Object> dataMap = new HashMap<String, Object>();
		dataMap.put("id", id);
		dataMap.put("name", sample.getName());
		dataMap.put("uid", sample.getUid());
		return super.exec("SampleMapping.update", dataMap);
	}

	@Override
	public Sample queryByCondition(String userId) {
		Map<String, Object> dataMap = new HashMap<String, Object>();
		dataMap.put("userId", userId);
		return super.queryOne("SampleMapping.queryByUserId", dataMap);
	}
	
}
